package com.my.study.designPatterns.observerPattern.improved;

import java.util.Observable;

public class WeatherData2 extends Observable {

    private float temperature;

    private float humidity;

    private float pressure;


    //push数据
    public void meassurementsChanged(){
        setChanged();
        notifyObservers();
    }

    public void setMeasurements(float temperature, float humidity, float pressure){
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        meassurementsChanged();
    }

    //getter  为Observer 主动pull数据做好准备
    public float getTemperature() {
        return temperature;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }
}
